\(\int (c+d x) \cot ^2(a+b x) \, dx\) [108]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 41 \[ \int (c+d x) \cot ^2(a+b x) \, dx=-c x-\frac {d x^2}{2}-\frac {(c+d x) \cot (a+b x)}{b}+\frac {d \log (\sin (a+b x))}{b^2} \]

[Out]

-c*x-1/2*d*x^2-(d*x+c)*cot(b*x+a)/b+d*ln(sin(b*x+a))/b^2

Rubi [A] (verified)

Time = 0.03 (sec) , antiderivative size = 41, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3801, 3556} \[ \int (c+d x) \cot ^2(a+b x) \, dx=\frac {d \log (\sin (a+b x))}{b^2}-\frac {(c+d x) \cot (a+b x)}{b}-c x-\frac {d x^2}{2} \]

[In]

Int[(c + d*x)*Cot[a + b*x]^2,x]

[Out]

-(c*x) - (d*x^2)/2 - ((c + d*x)*Cot[a + b*x])/b + (d*Log[Sin[a + b*x]])/b^2

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {(c+d x) \cot (a+b x)}{b}+\frac {d \int \cot (a+b x) \, dx}{b}-\int (c+d x) \, dx \\ & = -c x-\frac {d x^2}{2}-\frac {(c+d x) \cot (a+b x)}{b}+\frac {d \log (\sin (a+b x))}{b^2} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.59 (sec) , antiderivative size = 82, normalized size of antiderivative = 2.00 \[ \int (c+d x) \cot ^2(a+b x) \, dx=-\frac {c \cot (a+b x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(a+b x)\right )}{b}+\frac {d \log (\sin (a+b x))}{b^2}-\frac {d x \csc (a) (2 \cos (a)+b x \sin (a))}{2 b}+\frac {d x \csc (a) \csc (a+b x) \sin (b x)}{b} \]

[In]

Integrate[(c + d*x)*Cot[a + b*x]^2,x]

[Out]

-((c*Cot[a + b*x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[a + b*x]^2])/b) + (d*Log[Sin[a + b*x]])/b^2 - (d*x*Csc[
a]*(2*Cos[a] + b*x*Sin[a]))/(2*b) + (d*x*Csc[a]*Csc[a + b*x]*Sin[b*x])/b

Maple [A] (verified)

Time = 1.26 (sec) , antiderivative size = 64, normalized size of antiderivative = 1.56

method result size
default \(-\frac {d \,x^{2}}{2}-c x +\frac {\frac {d a \cot \left (x b +a \right )}{b}-c \cot \left (x b +a \right )+\frac {d \left (-\left (x b +a \right ) \cot \left (x b +a \right )+\ln \left (\sin \left (x b +a \right )\right )\right )}{b}}{b}\) \(64\)
parallelrisch \(\frac {-d \,x^{2} b^{2}-2 \cot \left (x b +a \right ) d x b -2 c x \,b^{2}-2 \cot \left (x b +a \right ) c b +2 d \ln \left (\tan \left (x b +a \right )\right )-d \ln \left (\sec \left (x b +a \right )^{2}\right )}{2 b^{2}}\) \(66\)
risch \(-\frac {d \,x^{2}}{2}-c x -\frac {2 i d x}{b}-\frac {2 i d a}{b^{2}}-\frac {2 i \left (d x +c \right )}{b \left ({\mathrm e}^{2 i \left (x b +a \right )}-1\right )}+\frac {d \ln \left ({\mathrm e}^{2 i \left (x b +a \right )}-1\right )}{b^{2}}\) \(69\)
norman \(\frac {-\frac {c}{b}-c x \tan \left (x b +a \right )-\frac {d x}{b}-\frac {d \,x^{2} \tan \left (x b +a \right )}{2}}{\tan \left (x b +a \right )}+\frac {d \ln \left (\tan \left (x b +a \right )\right )}{b^{2}}-\frac {d \ln \left (1+\tan \left (x b +a \right )^{2}\right )}{2 b^{2}}\) \(76\)

[In]

int((d*x+c)*cot(b*x+a)^2,x,method=_RETURNVERBOSE)

[Out]

-1/2*d*x^2-c*x+1/b*(1/b*d*a*cot(b*x+a)-c*cot(b*x+a)+1/b*d*(-(b*x+a)*cot(b*x+a)+ln(sin(b*x+a))))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 97 vs. \(2 (39) = 78\).

Time = 0.25 (sec) , antiderivative size = 97, normalized size of antiderivative = 2.37 \[ \int (c+d x) \cot ^2(a+b x) \, dx=-\frac {2 \, b d x - d \log \left (-\frac {1}{2} \, \cos \left (2 \, b x + 2 \, a\right ) + \frac {1}{2}\right ) \sin \left (2 \, b x + 2 \, a\right ) + 2 \, b c + 2 \, {\left (b d x + b c\right )} \cos \left (2 \, b x + 2 \, a\right ) + {\left (b^{2} d x^{2} + 2 \, b^{2} c x\right )} \sin \left (2 \, b x + 2 \, a\right )}{2 \, b^{2} \sin \left (2 \, b x + 2 \, a\right )} \]

[In]

integrate((d*x+c)*cot(b*x+a)^2,x, algorithm="fricas")

[Out]

-1/2*(2*b*d*x - d*log(-1/2*cos(2*b*x + 2*a) + 1/2)*sin(2*b*x + 2*a) + 2*b*c + 2*(b*d*x + b*c)*cos(2*b*x + 2*a)
 + (b^2*d*x^2 + 2*b^2*c*x)*sin(2*b*x + 2*a))/(b^2*sin(2*b*x + 2*a))

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 104 vs. \(2 (36) = 72\).

Time = 0.22 (sec) , antiderivative size = 104, normalized size of antiderivative = 2.54 \[ \int (c+d x) \cot ^2(a+b x) \, dx=\begin {cases} \tilde {\infty } \left (c x + \frac {d x^{2}}{2}\right ) & \text {for}\: a = 0 \wedge b = 0 \\\left (c x + \frac {d x^{2}}{2}\right ) \cot ^{2}{\left (a \right )} & \text {for}\: b = 0 \\\tilde {\infty } \left (c x + \frac {d x^{2}}{2}\right ) & \text {for}\: a = - b x \\- c x - \frac {d x^{2}}{2} - \frac {c}{b \tan {\left (a + b x \right )}} - \frac {d x}{b \tan {\left (a + b x \right )}} - \frac {d \log {\left (\tan ^{2}{\left (a + b x \right )} + 1 \right )}}{2 b^{2}} + \frac {d \log {\left (\tan {\left (a + b x \right )} \right )}}{b^{2}} & \text {otherwise} \end {cases} \]

[In]

integrate((d*x+c)*cot(b*x+a)**2,x)

[Out]

Piecewise((zoo*(c*x + d*x**2/2), Eq(a, 0) & Eq(b, 0)), ((c*x + d*x**2/2)*cot(a)**2, Eq(b, 0)), (zoo*(c*x + d*x
**2/2), Eq(a, -b*x)), (-c*x - d*x**2/2 - c/(b*tan(a + b*x)) - d*x/(b*tan(a + b*x)) - d*log(tan(a + b*x)**2 + 1
)/(2*b**2) + d*log(tan(a + b*x))/b**2, True))

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 292 vs. \(2 (39) = 78\).

Time = 0.36 (sec) , antiderivative size = 292, normalized size of antiderivative = 7.12 \[ \int (c+d x) \cot ^2(a+b x) \, dx=-\frac {2 \, {\left (b x + a + \frac {1}{\tan \left (b x + a\right )}\right )} c - \frac {2 \, {\left (b x + a + \frac {1}{\tan \left (b x + a\right )}\right )} a d}{b} + \frac {{\left ({\left (b x + a\right )}^{2} \cos \left (2 \, b x + 2 \, a\right )^{2} + {\left (b x + a\right )}^{2} \sin \left (2 \, b x + 2 \, a\right )^{2} - 2 \, {\left (b x + a\right )}^{2} \cos \left (2 \, b x + 2 \, a\right ) + {\left (b x + a\right )}^{2} - {\left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} - 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right )} \log \left (\cos \left (b x + a\right )^{2} + \sin \left (b x + a\right )^{2} + 2 \, \cos \left (b x + a\right ) + 1\right ) - {\left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} - 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right )} \log \left (\cos \left (b x + a\right )^{2} + \sin \left (b x + a\right )^{2} - 2 \, \cos \left (b x + a\right ) + 1\right ) + 4 \, {\left (b x + a\right )} \sin \left (2 \, b x + 2 \, a\right )\right )} d}{{\left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} - 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right )} b}}{2 \, b} \]

[In]

integrate((d*x+c)*cot(b*x+a)^2,x, algorithm="maxima")

[Out]

-1/2*(2*(b*x + a + 1/tan(b*x + a))*c - 2*(b*x + a + 1/tan(b*x + a))*a*d/b + ((b*x + a)^2*cos(2*b*x + 2*a)^2 +
(b*x + a)^2*sin(2*b*x + 2*a)^2 - 2*(b*x + a)^2*cos(2*b*x + 2*a) + (b*x + a)^2 - (cos(2*b*x + 2*a)^2 + sin(2*b*
x + 2*a)^2 - 2*cos(2*b*x + 2*a) + 1)*log(cos(b*x + a)^2 + sin(b*x + a)^2 + 2*cos(b*x + a) + 1) - (cos(2*b*x +
2*a)^2 + sin(2*b*x + 2*a)^2 - 2*cos(2*b*x + 2*a) + 1)*log(cos(b*x + a)^2 + sin(b*x + a)^2 - 2*cos(b*x + a) + 1
) + 4*(b*x + a)*sin(2*b*x + 2*a))*d/((cos(2*b*x + 2*a)^2 + sin(2*b*x + 2*a)^2 - 2*cos(2*b*x + 2*a) + 1)*b))/b

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 1151 vs. \(2 (39) = 78\).

Time = 0.55 (sec) , antiderivative size = 1151, normalized size of antiderivative = 28.07 \[ \int (c+d x) \cot ^2(a+b x) \, dx=\text {Too large to display} \]

[In]

integrate((d*x+c)*cot(b*x+a)^2,x, algorithm="giac")

[Out]

-1/2*(b^2*d*x^2*tan(1/2*b*x)^2*tan(1/2*a) + b^2*d*x^2*tan(1/2*b*x)*tan(1/2*a)^2 + 2*b^2*c*x*tan(1/2*b*x)^2*tan
(1/2*a) + 2*b^2*c*x*tan(1/2*b*x)*tan(1/2*a)^2 - b*d*x*tan(1/2*b*x)^2*tan(1/2*a)^2 - b^2*d*x^2*tan(1/2*b*x) - b
^2*d*x^2*tan(1/2*a) - b*c*tan(1/2*b*x)^2*tan(1/2*a)^2 - 2*b^2*c*x*tan(1/2*b*x) + b*d*x*tan(1/2*b*x)^2 - 2*b^2*
c*x*tan(1/2*a) + 4*b*d*x*tan(1/2*b*x)*tan(1/2*a) - d*log(16*(tan(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^3*ta
n(1/2*a)^3 + tan(1/2*b*x)^2*tan(1/2*a)^4 - 2*tan(1/2*b*x)^3*tan(1/2*a) - 4*tan(1/2*b*x)^2*tan(1/2*a)^2 - 2*tan
(1/2*b*x)*tan(1/2*a)^3 + tan(1/2*b*x)^2 + 2*tan(1/2*b*x)*tan(1/2*a) + tan(1/2*a)^2)/(tan(1/2*b*x)^4*tan(1/2*a)
^4 + 2*tan(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^2*tan(1/2*a)^4 + tan(1/2*b*x)^4 + 4*tan(1/2*b*x)^2*tan(1/2
*a)^2 + tan(1/2*a)^4 + 2*tan(1/2*b*x)^2 + 2*tan(1/2*a)^2 + 1))*tan(1/2*b*x)^2*tan(1/2*a) + b*d*x*tan(1/2*a)^2
- d*log(16*(tan(1/2*b*x)^4*tan(1/2*a)^2 + 2*tan(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4*tan(1/2*b*x)^2*tan(1/2*a)^2 - 2*tan(1/2*b*x)*ta
n(1/2*a)^3 + tan(1/2*b*x)^2 + 2*tan(1/2*b*x)*tan(1/2*a) + tan(1/2*a)^2)/(tan(1/2*b*x)^4*tan(1/2*a)^4 + 2*tan(1
/2*b*x)^4*tan(1/2*a)^2 + 2*tan(1/2*b*x)^2*tan(1/2*a)^4 + tan(1/2*b*x)^4 + 4*tan(1/2*b*x)^2*tan(1/2*a)^2 + tan(
1/2*a)^4 + 2*tan(1/2*b*x)^2 + 2*tan(1/2*a)^2 + 1))*tan(1/2*a) - b*c)/(b^2*tan(1/2*b*x)^2*tan(1/2*a) + b^2*tan(
1/2*b*x)*tan(1/2*a)^2 - b^2*tan(1/2*b*x) - b^2*tan(1/2*a))

Mupad [B] (verification not implemented)

Time = 22.93 (sec) , antiderivative size = 67, normalized size of antiderivative = 1.63 \[ \int (c+d x) \cot ^2(a+b x) \, dx=-\frac {d\,x^2}{2}+\frac {d\,\ln \left ({\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{b\,x\,2{}\mathrm {i}}-1\right )}{b^2}-\frac {\left (c+d\,x\right )\,2{}\mathrm {i}}{b\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}+b\,x\,2{}\mathrm {i}}-1\right )}-\frac {x\,\left (b\,c+d\,2{}\mathrm {i}\right )}{b} \]

[In]

int(cot(a + b*x)^2*(c + d*x),x)

[Out]

(d*log(exp(a*2i)*exp(b*x*2i) - 1))/b^2 - (d*x^2)/2 - ((c + d*x)*2i)/(b*(exp(a*2i + b*x*2i) - 1)) - (x*(d*2i +
b*c))/b